package com.zh.ssmshirofreemarker.test;

import java.util.regex.Matcher;

public class Pattern {

    public static void main(String[] args){

//        String content = "I am noob " + "from runoob.com.";
//        String pattern = ".*runoob.*";
//        boolean isMatch = java.util.regex.Pattern.matches(pattern,content);
//        System.out.println("字符串中是否包含了 'runoob' 子字符串?" + isMatch);

        //按指定模式在字符串中查找
        String line = "This order was placed for QT3000! OK ?";

        String pattern = "(\\D*)(\\d+)(.*)";

        //创建Pattern 对象

        java.util.regex.Pattern r = java.util.regex.Pattern.compile(pattern);
        //现在创建matcher对象
        Matcher m = r.matcher(line);

        if(m.find()){

            System.out.println("Found value :" + m.group(0));
            System.out.println("Found value :" + m.group(1));
            System.out.println("Found value :" + m.group(2));
            System.out.println("Found value :" + m.group(3));

        } else {
            System.out.println("NO MATCH");
        }
    }
}
